package com.study.utils;

import cn.hutool.core.util.NumberUtil;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author zhuzi
 * 2025/1/30 23:18
 */
public class SysUtils {
    /**
     * 计算收益率
     *
     * @param end
     * @param start
     * @return
     */
    public static BigDecimal syl(BigDecimal end, BigDecimal start) {
        if (start == null) {
            return null;
        }
        BigDecimal div = cn.hutool.core.util.NumberUtil.div(end, start);
        BigDecimal sub = cn.hutool.core.util.NumberUtil.sub(div, 1);
        return NumberUtil.mul(sub, 100).setScale(3, RoundingMode.HALF_UP);
    }

}
